package com.utc.fjc.stylesheet;

import java.util.Map;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;

import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCPropertyDescriptor;
import com.teamcenter.rac.viewer.stylesheet.beans.LOVUIComponentPropertyBean;

public class FJCNameTextField extends LOVUIComponentPropertyBean {

	private String ObjectName = "object_name";

	public FJCNameTextField(FormToolkit formtoolkit, Composite composite,
			boolean flag, Map<Object, Object> map) {
		super(formtoolkit, composite, flag, map);
	}

	public void load(TCPropertyDescriptor des) throws Exception {
		super.load(des);

		InterfaceAIFComponent[] targets = AIFUtility.getCurrentApplication()
				.getTargetComponents();

		if ((targets != null) && (targets.length > 0)) {
			TCComponent tcSelectedComp = (TCComponent) targets[0];
			if (tcSelectedComp.getType().equalsIgnoreCase("Ng4_PartRevision")
					|| tcSelectedComp.getType().equalsIgnoreCase(
							"Ng4_DesignRevision")) {
				String objectName = tcSelectedComp.getProperty(ObjectName);
				des.setDefaultValue(objectName);
				getLOVUIComponent().setSelectedValue(objectName);

			} else {
				des.setDefaultValue("");
			}
		}

	}

	@Override
	public void load(TCProperty paramTCProperty) throws Exception {
		// TODO Auto-generated method stub
		super.load(paramTCProperty);
	}

	@Override
	public void closeSignaled() {
		// TODO Auto-generated method stub
		super.closeSignaled();
	}

	@Override
	public boolean isPropertyModified(TCProperty paramTCProperty)
			throws Exception {
		// TODO Auto-generated method stub
		return super.isPropertyModified(paramTCProperty);
	}

	@Override
	public boolean isMandatory() {
		// TODO Auto-generated method stub
		return super.isMandatory();
	}

}
